package com.leyou.item.dto;

import com.leyou.common.dto.BaseDTO;
import com.leyou.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <h3>leyou-project</h3>
 * <p></p>
 *
 * @author : hhw
 * @date : 2020-05-22 09:21
 **/
@Data
@NoArgsConstructor(staticName = "of")
@EqualsAndHashCode(callSuper = true)
public class CategoryDTO extends BaseDTO{
    private Long id;
    private String name;
    private Long parentId;
    private Boolean isParent;
    private Integer sort;

   public CategoryDTO(BaseEntity entity) {
        super(entity);
    }

    public static <T extends BaseEntity> List<CategoryDTO> convertEntityList(Collection<T> list) {
        if(list == null){
            return null;
        }
        return list.stream().map(CategoryDTO::new).collect(Collectors.toList());
    }
}
